/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package userObservers;

import java.util.logging.Level;
import java.util.logging.Logger;
import org.OpenNI.*;

/**
 *
 * @author xvanek9
 */
public class PoseDetectedObserver implements IObserver<PoseDetectionEventArgs>{

    private PoseDetectionCapability posCap;
    private SkeletonCapability skelCap;
    
    public PoseDetectedObserver(PoseDetectionCapability posDetCap, SkeletonCapability skelCap){
        this.posCap = posDetCap;
        this.skelCap = skelCap;
    }
    
    @Override
    public void update(IObservable<PoseDetectionEventArgs> io, PoseDetectionEventArgs args) {
        System.out.println("Pose " + args.getPose() +  "detected for " + args.getUser());
        try {
            posCap.stopPoseDetection(args.getUser());
            skelCap.requestSkeletonCalibration(args.getUser(), true);
            System.out.println("Calibrating skeleton");
        } catch (StatusException ex) {
            Logger.getLogger(PoseDetectedObserver.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
}
